import GeekLayout from "@/pages/Layout/index";
import Login from "@/pages/Login/index";
import { createBrowserRouter } from 'react-router-dom'
import { AuthRoute } from "@/components/AuthRoute";
import { lazy, Suspense } from "react"
//打包优化 路由懒加载 lazy函数对组件进行导入 (路由的js资源只有在被访问时才被加载) 按需加载
// const Home = lazy(() => import("@/pages/Home"))
const UserList = lazy(() => import("@/pages/AdminUser/idnex"))
const User = lazy(() => import("@/pages/User"))
const Password = lazy(() => import("@/pages/Password"))
const Mine = lazy(() => import("@/pages/Mine"))
const PowerBi = lazy(() => import("@/pages/PowerBi"))

const router = createBrowserRouter([
    {
        path: "/",
        element: <AuthRoute><GeekLayout /></AuthRoute>,  //插槽写法
        children: [
            {
                index: true,
                // path: "adminuser/page",
                element: <Suspense fallback={"加载中"}><UserList /></Suspense>
            },
            {
                path: "user/page",
                element: <Suspense fallback={"加载中"}><User /></Suspense>
            },
            // {
            //     path: "admuser/password",
            //     element: <Suspense fallback={"加载中"}><Password /></Suspense>
            // },
            {
                path: "Mine/page",
                element: <Suspense fallback={"加载中"}><Mine /></Suspense>
            },
            {
                path: "/mmgdigitalbrain/pageembed",
                element: <Suspense fallback={"加载中"}><PowerBi /></Suspense>
            }
        ]
    },
    // {
    //     path: "/",
    //     element: <Home />
    // },
    {
        path: "/login",
        element: <Login />
    }
])
export default router